package com.restaurant.application.minifacade.data;

import com.google.common.collect.Lists;
import com.nebutown.generation.Convert;
import com.nebutown.generation.PickableBean;

import java.util.List;

public class StatusBO implements PickableBean {

    public static final String FN_STATUS = "status";

    public static final List<String> FIELD_NAMES = Lists.newArrayList(
            FN_STATUS);

    private String status;

    public StatusBO(String status) {
        setStatus(status);
    }

    public StatusBO() {
    }

    public StatusBO duplicate() {
        StatusBO result = new StatusBO();
        result.status = this.status;
        return result;
    }

    @Override
    public String toString() {
        return Convert.toJson(this);
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String value) {
        this.status = value;
    }

    public StatusBO withStatus(String value) {
        setStatus(value);
        return this;
    }

    public StatusBO withStatus(String value, String defaultValue) {
        setStatus(value == null ? defaultValue : value);
        return this;
    }

    public Object getValueOf(String name) {
        switch (name) {
            case "status":
                return getStatus();
        }
        return null;
    }

    public boolean hasField(String name) {
        return FIELD_NAMES.contains(name);
    }

    @Override
    public int hashCode() {
        return signature().hashCode();
    }

    @Override
    public boolean equals(Object o) {
        if (!(o instanceof StatusBO)) return false;
        return signature().equals(((StatusBO) o).signature());
    }

    public String signature() {
        throw new RuntimeException("Bean StatusBO has no signature defined, no hash code or equals possible.");
    }
}
